package com.example.analysis.controller;

import com.example.analysis.entity.Course;
import com.example.analysis.entity.Teacher;
import com.example.analysis.service.ElectionListService;
import com.example.analysis.utils.Response;
import com.example.analysis.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/analysis_grade")
public class ElectionListController {
    @Resource
    private ElectionListService electionListService;

    @GetMapping("/normality")
    Response<List<ResultVO>> normality(String courseId, String teacherId, String semester) {
        System.out.println(courseId + " - " + semester + " - " + teacherId);
        List<ResultVO> resultVOList = electionListService.normalityTest(courseId, teacherId, semester);
        return new Response<>(true, "success", resultVOList, 20000);
    }

    @GetMapping("/discrimination_analysis")
    Response<List<ResultVO>> discriminationAnalysis(String courseId, String teacherId, double quantile, String semester) {
        List<ResultVO> resultVOList = electionListService.discriminationAnalysis(courseId, teacherId, quantile, semester);
        return new Response<>(true, "成功", resultVOList, 20000);
    }

    @GetMapping("/class_grade_difference")
    Response<List<ResultVO>> gradeDifference(String courseId, String teacherId, String semester) {
        System.out.println(courseId + ", " + teacherId + ", " + semester);
        List<ResultVO> resultVOList = electionListService.courseGradeAnalysis(courseId, teacherId, semester);
        return new Response<>(true, "成功", resultVOList, 20000);
    }

    // 查课程
    @GetMapping("/courses")
    Response<List<Course>> getCourses() {
        List<Course> courses = electionListService.getCourses();
        return new Response<>(true, "success", courses, 20000);
    }

    // 查教师
    @GetMapping("/teachers")
    Response<List<Teacher>> getTeachers(String courseId) {
        List<Teacher> teachers = electionListService.getTeachers(courseId);
        return new Response<>(true, "success", teachers, 20000);
    }

    // 查学期
    @GetMapping("/semesters")
    Response<List<String>> getSemester(String courseId, String teacherId) {
        List<String> semesters = electionListService.getSemesters(courseId, teacherId);
        return new Response<>(true, "success", semesters, 20000);
    }
}
